package models

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId  int     `gorm:"type:int(10)"`
	OrderSn string  `gorm:"type:varchar(50)"`
	Amount  float64 `gorm:"type:decimal(10,2)"`
	Status  int     `gorm:"type:int;default:1;comment:订单状态: 1 已付款 0 未付款"`
}

func (o *Order) Create() error {
	return DB.Create(&o).Error
}

type OrderGoods struct {
	gorm.Model
	OrderId    int     `gorm:"type:int(10)"`
	GoodsId    int     `gorm:"type:int(10)"`
	Num        int     `gorm:"type:int(10)"`
	GoodsTitle string  `gorm:"type:varchar(50)"`
	GoodsPrice float64 `gorm:"type:decimal(10,2)"`
}

func (og *OrderGoods) Create() error {
	return DB.Create(&og).Error
}
